package com.components.cachewebview.adapter

import android.net.Uri
import com.tencent.smtt.export.external.interfaces.WebResourceRequest

class WebResourceRequestAdapter(private var mWebResourceRequest: WebResourceRequest?) :
    WebResourceRequest {

    companion object {
        fun adapter(x5Request: WebResourceRequest): WebResourceRequestAdapter {
            return WebResourceRequestAdapter(x5Request)
        }
    }

    override fun getUrl(): Uri? {
        return mWebResourceRequest?.url
    }

    override fun isForMainFrame(): Boolean {
        return mWebResourceRequest?.isForMainFrame ?: false
    }

    override fun isRedirect(): Boolean {
        return mWebResourceRequest?.isRedirect ?: false
    }

    override fun hasGesture(): Boolean {
        return mWebResourceRequest?.hasGesture() ?: false
    }

    override fun getMethod(): String {
        return mWebResourceRequest?.method ?: ""
    }

    override fun getRequestHeaders(): MutableMap<String, String> {
        return mWebResourceRequest?.requestHeaders ?: mutableMapOf()
    }
}